package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.service.ISignService;
import cn.wolfcode.trip.base.util.JSONResult;
import cn.wolfcode.trip.base.util.SignMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("signs")
public class SignController {

    @Autowired
    private ISignService signService;

    /**
     * 用户签到
     * @param userId
     * @return
     */
    @GetMapping("/{userId}/credits/{creditCatalogId}")
    public SignMessage sign(@PathVariable Long userId,@PathVariable Long creditCatalogId){
        SignMessage result = signService.sign(userId,creditCatalogId);
        return result;
    }




    @GetMapping("/isSign/{userId}")
    public JSONResult isSign(@PathVariable Long userId){
        JSONResult result = new JSONResult();
        boolean isSign  = signService.isSign(userId);
        if(!isSign){
            result.mark("签过到啦");
        }
        return result;
    }
}
